import React, { Component } from 'react'
import PubSub from 'pubsub-js';
import './index.css'
export default function Header() {
    function sendTitle(e){
        if(e.code !== 'Enter') return ;
        PubSub.publish('addTodo', e.target.value.trim())
        e.target.value = ''
    }
    return (
        <div className="todo-header">
            <input type="text" placeholder="请输入你的任务名称，按回车键确认" onKeyUp={sendTitle}/>
        </div>
    )
}
